<?php
$rowTop = $rowCATTC = $rowCAHT = $rowNbT = $rowNbA = $rowTm = $rowTp = $rowEc = $rowMo = $rowAc = $rowFpr = $rowPc = $rowRp = $rowA = $rowAl = $rowTa = $rowE = "";
if(!empty($marcheIds)) {
    foreach($marcheIds as $marcheId) {
        $marcheName = "";
        foreach($marches as $idx => $marche) {
            if($idx == $marcheId)
                $marcheName = $marche;
        }
        $rowTop .= '
            <td class="width250">
                <p>'.ucwords(mb_strtolower($marcheName, 'UTF-8')).'</p>
                <table>
                    <tr>
                        <td class="bre"><p>Budget</p></td>
                        <td class="bre"><p>Réel</p></td>
                        <td class="bre"><p>Ecart</p></td>
                    </tr>
                </table>
            </td>';

        ///// Ligne des CA pour chaque marche
        $reelcattc = $reelcaht = 0;
        foreach($caCumulMarche as $b_caCumulMarche) {
            if($marcheId == $b_caCumulMarche['idMarche']) {
                $reelcattc = $b_caCumulMarche['ca_ttc'];
                $reelcaht = $b_caCumulMarche['ca_ht'];
            }
        }
        $ecattc = $reelcattc - $marcheBudgets[$marcheId]['cattc'];
        $ecaht = $reelcaht - $marcheBudgets[$marcheId]['caht'];
        $rowCATTC .= '
            <td class="width250">
                <table>
                    <tr>
                        <td class="bre"><p>'.number_format($marcheBudgets[$marcheId]['cattc'],2,',', ' ').'</p></td>
                        <td class="bre"><p>'.number_format($reelcattc,2,',', ' ').'</p></td>
                        <td class="bre"><p>'.number_format($ecattc,2,',', ' ').'</p></td>
                    </tr>
                </table>
            </td>';

        $rowCAHT .= '
            <td class="width250">
                <table>
                    <tr>
                        <td class="bre"><p>'.number_format($marcheBudgets[$marcheId]['caht'],2,',', ' ').'</p></td>
                        <td class="bre"><p>'.number_format($reelcaht,2,',', ' ').'</p></td>
                        <td class="bre"><p>'.number_format($ecaht,2,',', ' ').'</p></td>
                    </tr>
                </table>
            </td>';

        ///// Ligne des Transactions pour chaque boutique
        $reelnbt  = 0;
        foreach($nbTCumulMarche as $b_nbTCumulMarche) {
            if($marcheId == $b_nbTCumulMarche['idMarche']) {
                $reelnbt = $b_nbTCumulMarche['nbTransaction'];
            }
        }
        $enbt = $reelnbt - $marcheBudgets[$marcheId]['nbt'];
        $rowNbT .= '
            <td class="width250">
                <table>
                    <tr>
                        <td class="bre"><p>'.number_format($marcheBudgets[$marcheId]['nbt'],0,',', ' ').'</p></td>
                        <td class="bre"><p>'.number_format($reelnbt,0,',', ' ').'</p></td>
                        <td class="bre"><p>'.number_format($enbt,0,',', ' ').'</p></td>
                    </tr>
                </table>
            </td>';

        ///// Ligne des TM pour chaque boutique
        $reeltm  = 0;
        foreach($tmCumulMarche as $b_tmCumulMarche) {
            if($marcheId == $b_caCumulMarche['idMarche']) {
                $reeltm = $b_tmCumulMarche['valeur']/$b_tmCumulMarche['nombre'];
            }
        }
        $rowTm .= '
            <td class="width250">
                <table>
                    <tr>
                        <td class="bre"><p>&nbsp;</p></td>
                        <td class="bre"><p>'.number_format($reeltm,2,',', ' ').'</p></td>
                        <td class="bre"><p>&nbsp;</p></td>
                    </tr>
                </table>
            </td>';

        ///// Ligne des Articles pour chaque boutique
        $reelnba  = 0;
        foreach($nbACumulMarche as $b_nbACumulMarche) {
            if($marcheId == $b_nbACumulMarche['idMarche']) {
                $reelnba = $b_nbACumulMarche['nbArticle'];
            }
        }
        $rowNbA .= '
            <td class="width250">
                <table>
                    <tr>
                        <td class="bre"><p>&nbsp;</p></td>
                        <td class="bre"><p>'.number_format($reelnba,0,',', ' ').'</p></td>
                        <td class="bre"><p>&nbsp;</p></td>
                    </tr>
                </table>
            </td>';

        ///// Ligne des Taux de prise pour chaque boutique
        $tx  = 0;
        if($reelnbt > 0) $tx = $reelnba/$reelnbt;
        $rowTp .= '
            <td class="width250">
                <table>
                    <tr>
                        <td class="bre"><p>&nbsp;</p></td>
                        <td class="bre"><p>'.number_format($tx,2,',', ' ').'</p></td>
                        <td class="bre"><p>&nbsp;</p></td>
                    </tr>
                </table>
            </td>';

        ///// Ligne des EC pour chaque boutique
        $reelec  = 0;
        foreach($ecCumulMarche as $b_ecCumulMarche) {
            if($marcheId == $b_ecCumulMarche['idMarche']) {
                $reelec = $b_ecCumulMarche['ec'];
            }
        }
        $rowEc .= '
            <td class="width250">
                <table>
                    <tr>
                        <td class="bre"><p>&nbsp;</p></td>
                        <td class="bre"><p>'.number_format($reelec,2,',', ' ').'</p></td>
                        <td class="bre"><p>&nbsp;</p></td>
                    </tr>
                </table>
            </td>';

        ///// Ligne des MO pour chaque boutique
        $reelmo  = 0;
        foreach($moCumulMarche as $b_moCumulMarche) {
            if($marcheId == $b_moCumulMarche['idMarche']) {
                $reelmo = $b_moCumulMarche['mo'];
            }
        }
        $rowMo .= '
            <td class="width250">
                <table>
                    <tr>
                        <td class="bre"><p>&nbsp;</p></td>
                        <td class="bre"><p>'.number_format($reelmo,2,',', ' ').'</p></td>
                        <td class="bre"><p>&nbsp;</p></td>
                    </tr>
                </table>
            </td>';

        ///// Ligne des AC pour chaque boutique
        $reelac  = 0;
        foreach($acCumulMarche as $b_acCumulMarche) {
            if($marcheId == $b_acCumulMarche['idMarche']) {
                $reelac = $b_acCumulMarche['nbAnnulation'];
            }
        }
        $rowAc .= '
            <td class="width250">
                <table>
                    <tr>
                        <td class="bre"><p>&nbsp;</p></td>
                        <td class="bre"><p>'.number_format($reelac,0,',', ' ').'</p></td>
                        <td class="bre"><p>&nbsp;</p></td>
                    </tr>
                </table>
            </td>';
        
        ///// Ligne des Frais personnel - Restaurant
        $rowFpr .= '
            <td class="width250">
                <table>
                    <tr>
                        <td class="bre"><p>'.number_format($marcheBudgets[$marcheId]['fpr'],2,',', ' ').'</p></td>
                        <td class="bre"><p>&nbsp;</p></td>
                        <td class="bre"><p>&nbsp;</p></td>
                    </tr>
                </table>
            </td>';
        
        ///// Ligne des Pertes connues
        $rowPc .= '
            <td class="width250">
                <table>
                    <tr>
                        <td class="bre"><p>'.number_format($marcheBudgets[$marcheId]['pc'],2,',', ' ').'</p></td>
                        <td class="bre"><p>&nbsp;</p></td>
                        <td class="bre"><p>&nbsp;</p></td>
                    </tr>
                </table>
            </td>';
        
        ///// Ligne des Repas personnel
        $rowRp .= '
            <td class="width250">
                <table>
                    <tr>
                        <td class="bre"><p>'.number_format($marcheBudgets[$marcheId]['rp'],2,',', ' ').'</p></td>
                        <td class="bre"><p>&nbsp;</p></td>
                        <td class="bre"><p>&nbsp;</p></td>
                    </tr>
                </table>
            </td>';
        
        ///// Ligne des Alimentaires
        $rowA .= '
            <td class="width250">
                <table>
                    <tr>
                        <td class="bre"><p>'.number_format($marcheBudgets[$marcheId]['a'],2,',', ' ').'</p></td>
                        <td class="bre"><p>&nbsp;</p></td>
                        <td class="bre"><p>&nbsp;</p></td>
                    </tr>
                </table>
            </td>';
        
        ///// Ligne des Alimentaire Laboratoire
        $rowAl .= '
            <td class="width250">
                <table>
                    <tr>
                        <td class="bre"><p>'.number_format($marcheBudgets[$marcheId]['al'],2,',', ' ').'</p></td>
                        <td class="bre"><p>&nbsp;</p></td>
                        <td class="bre"><p>&nbsp;</p></td>
                    </tr>
                </table>
            </td>';
        
        ///// Ligne des totaux Alimentaire
        $rowTa .= '
            <td class="width250">
                <table>
                    <tr>
                        <td class="bre"><p>'.number_format($marcheBudgets[$marcheId]['ta'],2,',', ' ').'</p></td>
                        <td class="bre"><p>&nbsp;</p></td>
                        <td class="bre"><p>&nbsp;</p></td>
                    </tr>
                </table>
            </td>';
        
        ///// Ligne des Emballages
        $rowE .= '
            <td class="width250">
                <table>
                    <tr>
                        <td class="bre"><p>'.number_format($marcheBudgets[$marcheId]['e'],2,',', ' ').'</p></td>
                        <td class="bre"><p>&nbsp;</p></td>
                        <td class="bre"><p>&nbsp;</p></td>
                    </tr>
                </table>
            </td>';
    }
}

if(!empty($storeIds)) {
    foreach ($stores as $store) {
        if(isset($budgets[$store->idStore])) {
            $bgcattc = $budgets[$store->idStore]['cattc'];
            $bgcaht = $budgets[$store->idStore]['caht'];
            $bgnbt = $budgets[$store->idStore]['nbt'];
            $bgfpr = $budgets[$store->idStore]['fpr'];
            $bgpc = $budgets[$store->idStore]['pc'];
            $bgrp = $budgets[$store->idStore]['rp'];
            $bga = $budgets[$store->idStore]['a'];
            $bgal = $budgets[$store->idStore]['al'];
            $bgta = $budgets[$store->idStore]['ta'];
            $bge = $budgets[$store->idStore]['e'];
        } else {
            $bgcattc = 0;
            $bgcaht = 0;
            $bgnbt = 0;
            $bgfpr = 0;
            $bgpc = 0;
            $bgrp = 0;
            $bga = 0;
            $bgal = 0;
            $bgta = 0;
            $bge = 0;
        }
        
        if(in_array($store->idStore, $storeIds)) {
            ///// Ligne des noms des boutiques choisies
            $rowTop .= '
                <td class="width250">
                    <p>'.ucwords(mb_strtolower($store->name, 'UTF-8')).' <span id="toggle'.$store->idStore.'" class="toogle plus" onclick="toggleStore(this);"></span></p>
                    <table>
                        <tr>
                            <td class="bre"><p>Budget</p></td>
                            <td class="bre"><p>Réel</p></td>
                            <td class="bre"><p>Ecart</p></td>
                        </tr>
                    </table>
                </td>';
            if(isset($wBudgets[$store->idStore])) {
                foreach($wBudgets[$store->idStore] as $idxw => $week) {
                    $rowTop .= '
                        <td class="width250 hide toggle'.$store->idStore.'">
                            <p class="blackcolor">Semaine '.$idxw.'</p>
                            <table>
                                <tr>
                                    <td class="bre"><p class="blackcolor">Budget</p></td>
                                    <td class="bre"><p class="blackcolor">Réel</p></td>
                                </tr>
                            </table>
                        </td>';
                }
            }

            ///// Ligne des CA pour chaque boutique
            $reelcattc = $reelcaht = 0;
            foreach($ca as $b_ca) {
                if($store->idStore == $b_ca['idStore']) {
                    $reelcattc = $b_ca['ca_ttc'];
                    $reelcaht = $b_ca['ca_ht'];
                }
            }
            $ecattc = $reelcattc - $bgcattc;
            $ecaht = $reelcaht - $bgcaht;
            $rowCATTC .= '
                <td class="width250">
                    <table>
                        <tr>
                            <td class="bre"><p>'.number_format($bgcattc,2,',', ' ').'</p></td>
                            <td class="bre"><p>'.number_format($reelcattc,2,',', ' ').'</p></td>
                            <td class="bre"><p>'.number_format($ecattc,2,',', ' ').'</p></td>
                        </tr>
                    </table>
                </td>';
            if(isset($wBudgets[$store->idStore])) {
                foreach($wBudgets[$store->idStore] as $idxw => $week) {
                    $rowCATTC .= '
                        <td class="width250 hide toggle'.$store->idStore.'">
                            <table>
                                <tr>
                                    <td class="bre"><p>'.number_format($week['cattc'],2,',', ' ').'</p></td>
                                    <td class="bre"><p>&nbsp;</p></td>
                                </tr>
                            </table>
                        </td>';
                }
            }

            $rowCAHT .= '
                <td class="width250">
                    <table>
                        <tr>
                            <td class="bre"><p>'.number_format($bgcaht,2,',', ' ').'</p></td>
                            <td class="bre"><p>'.number_format($reelcaht,2,',', ' ').'</p></td>
                            <td class="bre"><p>'.number_format($ecaht,2,',', ' ').'</p></td>
                        </tr>
                    </table>
                </td>';
            if(isset($wBudgets[$store->idStore])) {
                foreach($wBudgets[$store->idStore] as $idxw => $week) {
                    $rowCAHT .= '
                        <td class="width250 hide toggle'.$store->idStore.'">
                            <table>
                                <tr>
                                    <td class="bre"><p>'.number_format($week['caht'],2,',', ' ').'</p></td>
                                    <td class="bre"><p>&nbsp;</p></td>
                                </tr>
                            </table>
                        </td>';
                }
            }

            ///// Ligne des Transactions pour chaque boutique
            $reelnbt  = 0;
            foreach($nbT as $b_nbT) {
                if($store->idStore == $b_nbT['idStore']) {
                    $reelnbt = $b_nbT['nbTransaction'];
                }
            }
            $enbt = $reelnbt - $bgnbt;
            $rowNbT .= '
                <td class="width250">
                    <table>
                        <tr>
                            <td class="bre"><p>'.number_format($bgnbt,0,',', ' ').'</p></td>
                            <td class="bre"><p>'.number_format($reelnbt,0,',', ' ').'</p></td>
                            <td class="bre"><p>'.number_format($enbt,0,',', ' ').'</p></td>
                        </tr>
                    </table>
                </td>';
            if(isset($wBudgets[$store->idStore])) {
                foreach($wBudgets[$store->idStore] as $idxw => $week) {
                    $rowNbT .= '
                        <td class="width250 hide toggle'.$store->idStore.'">
                            <table>
                                <tr>
                                    <td class="bre"><p>'.number_format($week['nbt'],0,',', ' ').'</p></td>
                                    <td class="bre"><p>&nbsp;</p></td>
                                </tr>
                            </table>
                        </td>';
                }
            }

            ///// Ligne des TM pour chaque boutique
            $reeltm  = 0;
            foreach($tm as $b_tm) {
                if($store->idStore == $b_tm['idStore']) {
                    $reeltm = $b_tm['valeur']/$b_tm['nombre'];
                }
            }
            $rowTm .= '
                <td class="width250">
                    <table>
                        <tr>
                            <td class="bre"><p>&nbsp;</p></td>
                            <td class="bre"><p>'.number_format($reeltm,2,',', ' ').'</p></td>
                            <td class="bre"><p>&nbsp;</p></td>
                        </tr>
                    </table>
                </td>';
            if(isset($wBudgets[$store->idStore])) {
                foreach($wBudgets[$store->idStore] as $idxw => $week) {
                    $rowTm .= '
                        <td class="width250 hide toggle'.$store->idStore.'">
                            <table>
                                <tr>
                                    <td class="bre"><p>&nbsp;</p></td>
                                    <td class="bre"><p>&nbsp;</p></td>
                                </tr>
                            </table>
                        </td>';
                }
            }

            ///// Ligne des Articles pour chaque boutique
            $reelnba  = 0;
            foreach($nbA as $b_nbA) {
                if($store->idStore == $b_nbA['idStore']) {
                    $reelnba = $b_nbA['nbArticle'];
                }
            }
            $rowNbA .= '
                <td class="width250">
                    <table>
                        <tr>
                            <td class="bre"><p>&nbsp;</p></td>
                            <td class="bre"><p>'.number_format($reelnba,0,',', ' ').'</p></td>
                            <td class="bre"><p>&nbsp;</p></td>
                        </tr>
                    </table>
                </td>';
            if(isset($wBudgets[$store->idStore])) {
                foreach($wBudgets[$store->idStore] as $idxw => $week) {
                    $rowNbA .= '
                        <td class="width250 hide toggle'.$store->idStore.'">
                            <table>
                                <tr>
                                    <td class="bre"><p>&nbsp;</p></td>
                                    <td class="bre"><p>&nbsp;</p></td>
                                </tr>
                            </table>
                        </td>';
                }
            }

            ///// Ligne des Taux de prise pour chaque boutique
            $tx  = 0;
            if($reelnbt > 0) $tx = $reelnba/$reelnbt;
            $rowTp .= '
                <td class="width250">
                    <table>
                        <tr>
                            <td class="bre"><p>&nbsp;</p></td>
                            <td class="bre"><p>'.number_format($tx,2,',', ' ').'</p></td>
                            <td class="bre"><p>&nbsp;</p></td>
                        </tr>
                    </table>
                </td>';
            if(isset($wBudgets[$store->idStore])) {
                foreach($wBudgets[$store->idStore] as $idxw => $week) {
                    $rowTp .= '
                        <td class="width250 hide toggle'.$store->idStore.'">
                            <table>
                                <tr>
                                    <td class="bre"><p>&nbsp;</p></td>
                                    <td class="bre"><p>&nbsp;</p></td>
                                </tr>
                            </table>
                        </td>';
                }
            }
            
            ///// Ligne des EC pour chaque boutique
            $reelec  = 0;
            foreach($ec as $b_ec) {
                if($store->idStore == $b_ec['idStore']) {
                    $reelec = $b_ec['ec'];
                }
            }
            $rowEc .= '
                <td class="width250">
                    <table>
                        <tr>
                            <td class="bre"><p>&nbsp;</p></td>
                            <td class="bre"><p>'.number_format($reelec,2,',', ' ').'</p></td>
                            <td class="bre"><p>&nbsp;</p></td>
                        </tr>
                    </table>
                </td>';
            if(isset($wBudgets[$store->idStore])) {
                foreach($wBudgets[$store->idStore] as $idxw => $week) {
                    $rowEc .= '
                        <td class="width250 hide toggle'.$store->idStore.'">
                            <table>
                                <tr>
                                    <td class="bre"><p>&nbsp;</p></td>
                                    <td class="bre"><p>&nbsp;</p></td>
                                </tr>
                            </table>
                        </td>';
                }
            }

            ///// Ligne des MO pour chaque boutique
            $reelmo  = 0;
            foreach($mo as $b_mo) {
                if($store->idStore == $b_mo['idStore']) {
                    $reelmo = $b_mo['mo'];
                }
            }
            $rowMo .= '
                <td class="width250">
                    <table>
                        <tr>
                            <td class="bre"><p>&nbsp;</p></td>
                            <td class="bre"><p>'.number_format($reelmo,2,',', ' ').'</p></td>
                            <td class="bre"><p>&nbsp;</p></td>
                        </tr>
                    </table>
                </td>';
            if(isset($wBudgets[$store->idStore])) {
                foreach($wBudgets[$store->idStore] as $idxw => $week) {
                    $rowMo .= '
                        <td class="width250 hide toggle'.$store->idStore.'">
                            <table>
                                <tr>
                                    <td class="bre"><p>&nbsp;</p></td>
                                    <td class="bre"><p>&nbsp;</p></td>
                                </tr>
                            </table>
                        </td>';
                }
            }

            ///// Ligne des AC pour chaque boutique
            $reelac  = 0;
            foreach($ac as $b_ac) {
                if($store->idStore == $b_ac['idStore']) {
                    $reelac = $b_ac['nbAnnulation'];
                }
            }
            $rowAc .= '
                <td class="width250">
                    <table>
                        <tr>
                            <td class="bre"><p>&nbsp;</p></td>
                            <td class="bre"><p>'.number_format($reelac,2,',', ' ').'</p></td>
                            <td class="bre"><p>&nbsp;</p></td>
                        </tr>
                    </table>
                </td>';
            if(isset($wBudgets[$store->idStore])) {
                foreach($wBudgets[$store->idStore] as $idxw => $week) {
                    $rowAc .= '
                        <td class="width250 hide toggle'.$store->idStore.'">
                            <table>
                                <tr>
                                    <td class="bre"><p>&nbsp;</p></td>
                                    <td class="bre"><p>&nbsp;</p></td>
                                </tr>
                            </table>
                        </td>';
                }
            }
            
            ///// Ligne des frais personnel - restaurant
            $rowFpr .= '
                <td class="width250">
                    <table>
                        <tr>
                            <td class="bre"><p>'.number_format($bgfpr,2,',', ' ').'</p></td>
                            <td class="bre"><p>&nbsp;</p></td>
                            <td class="bre"><p>&nbsp;</p></td>
                        </tr>
                    </table>
                </td>';
            if(isset($wBudgets[$store->idStore])) {
                foreach($wBudgets[$store->idStore] as $idxw => $week) {
                    $rowFpr .= '
                        <td class="width250 hide toggle'.$store->idStore.'">
                            <table>
                                <tr>
                                    <td class="bre"><p>'.number_format($week['fpr'],2,',', ' ').'</p></td>
                                    <td class="bre"><p>&nbsp;</p></td>
                                </tr>
                            </table>
                        </td>';
                }
            }
            
            ///// Ligne des pertes continues
            $rowPc .= '
                <td class="width250">
                    <table>
                        <tr>
                            <td class="bre"><p>'.number_format($bgpc,2,',', ' ').'</p></td>
                            <td class="bre"><p>&nbsp;</p></td>
                            <td class="bre"><p>&nbsp;</p></td>
                        </tr>
                    </table>
                </td>';
            if(isset($wBudgets[$store->idStore])) {
                foreach($wBudgets[$store->idStore] as $idxw => $week) {
                    $rowPc .= '
                        <td class="width250 hide toggle'.$store->idStore.'">
                            <table>
                                <tr>
                                    <td class="bre"><p>'.number_format($week['pc'],2,',', ' ').'</p></td>
                                    <td class="bre"><p>&nbsp;</p></td>
                                </tr>
                            </table>
                        </td>';
                }
            }
            
            ///// Ligne des repas personnel
            $rowRp .= '
                <td class="width250">
                    <table>
                        <tr>
                            <td class="bre"><p>'.number_format($bgrp,2,',', ' ').'</p></td>
                            <td class="bre"><p>&nbsp;</p></td>
                            <td class="bre"><p>&nbsp;</p></td>
                        </tr>
                    </table>
                </td>';
            if(isset($wBudgets[$store->idStore])) {
                foreach($wBudgets[$store->idStore] as $idxw => $week) {
                    $rowRp .= '
                        <td class="width250 hide toggle'.$store->idStore.'">
                            <table>
                                <tr>
                                    <td class="bre"><p>'.number_format($week['rp'],2,',', ' ').'</p></td>
                                    <td class="bre"><p>&nbsp;</p></td>
                                </tr>
                            </table>
                        </td>';
                }
            }
            
            ///// Ligne des alimentaires
            $rowA .= '
                <td class="width250">
                    <table>
                        <tr>
                            <td class="bre"><p>'.number_format($bga,2,',', ' ').'</p></td>
                            <td class="bre"><p>&nbsp;</p></td>
                            <td class="bre"><p>&nbsp;</p></td>
                        </tr>
                    </table>
                </td>';
            if(isset($wBudgets[$store->idStore])) {
                foreach($wBudgets[$store->idStore] as $idxw => $week) {
                    $rowA .= '
                        <td class="width250 hide toggle'.$store->idStore.'">
                            <table>
                                <tr>
                                    <td class="bre"><p>'.number_format($week['a'],2,',', ' ').'</p></td>
                                    <td class="bre"><p>&nbsp;</p></td>
                                </tr>
                            </table>
                        </td>';
                }
            }
            
            ///// Ligne des alimentaires laboratoires
            $rowAl .= '
                <td class="width250">
                    <table>
                        <tr>
                            <td class="bre"><p>'.number_format($bgal,2,',', ' ').'</p></td>
                            <td class="bre"><p>&nbsp;</p></td>
                            <td class="bre"><p>&nbsp;</p></td>
                        </tr>
                    </table>
                </td>';
            if(isset($wBudgets[$store->idStore])) {
                foreach($wBudgets[$store->idStore] as $idxw => $week) {
                    $rowAl .= '
                        <td class="width250 hide toggle'.$store->idStore.'">
                            <table>
                                <tr>
                                    <td class="bre"><p>'.number_format($week['al'],2,',', ' ').'</p></td>
                                    <td class="bre"><p>&nbsp;</p></td>
                                </tr>
                            </table>
                        </td>';
                }
            }
            
            ///// Ligne des totaux alimentaires
            $rowTa .= '
                <td class="width250">
                    <table>
                        <tr>
                            <td class="bre"><p>'.number_format($bgta,2,',', ' ').'</p></td>
                            <td class="bre"><p>&nbsp;</p></td>
                            <td class="bre"><p>&nbsp;</p></td>
                        </tr>
                    </table>
                </td>';
            if(isset($wBudgets[$store->idStore])) {
                foreach($wBudgets[$store->idStore] as $idxw => $week) {
                    $rowTa .= '
                        <td class="width250 hide toggle'.$store->idStore.'">
                            <table>
                                <tr>
                                    <td class="bre"><p>'.number_format($week['ta'],2,',', ' ').'</p></td>
                                    <td class="bre"><p>&nbsp;</p></td>
                                </tr>
                            </table>
                        </td>';
                }
            }
            
            ///// Ligne des emballages
            $rowE .= '
                <td class="width250">
                    <table>
                        <tr>
                            <td class="bre"><p>'.number_format($bge,2,',', ' ').'</p></td>
                            <td class="bre"><p>&nbsp;</p></td>
                            <td class="bre"><p>&nbsp;</p></td>
                        </tr>
                    </table>
                </td>';
            if(isset($wBudgets[$store->idStore])) {
                foreach($wBudgets[$store->idStore] as $idxw => $week) {
                    $rowE .= '
                        <td class="width250 hide toggle'.$store->idStore.'">
                            <table>
                                <tr>
                                    <td class="bre"><p>'.number_format($week['e'],2,',', ' ').'</p></td>
                                    <td class="bre"><p>&nbsp;</p></td>
                                </tr>
                            </table>
                        </td>';
                }
            }
        }
    }
}
?>
<table class="table-hover">
    <tr class="top">
        <td></td>
        <?php echo $rowTop; ?>
    </tr>
    <tr class="value ca">
        <td class="lRubrique"><p>CA TTC</p></td>
        <?php echo $rowCATTC; ?>
    </tr>
    <tr class="value ca">
        <td class="lRubrique"><p>CA HT</p></td>
        <?php echo $rowCAHT; ?>
    </tr>
    <tr class="value tv">
        <td class="lRubrique"><p>Nombre de transactions</p></td>
        <?php echo $rowNbT; ?>
    </tr>
    <tr class="value ca">
        <td class="lRubrique"><p>T.M.</p></td>
        <?php echo $rowTm; ?>
    </tr>
    <tr class="value tv">
        <td class="lRubrique"><p>Nombre d'article vendus</p></td>
        <?php echo $rowNbA; ?>
    </tr>
    <tr class="value tv">
        <td class="lRubrique"><p>Taux de prise</p></td>
        <?php echo $rowTp; ?>
    </tr>
    <tr class="value ec">
        <td class="lRubrique"><p>Ecarts caisse</p></td>
        <?php echo $rowEc; ?>
    </tr>
    <tr class="value mo">
        <td class="lRubrique"><p>Main d'oeuvre</p></td>
        <?php echo $rowMo; ?>
    </tr>
    <tr class="value ac">
        <td class="lRubrique"><p>Annulation caisse</p></td>
        <?php echo $rowAc; ?>
    </tr>
    <tr class="value">
        <td class="lRubrique"><p>Frais de personnel - Restaurant</p></td>
        <?php echo $rowFpr; ?>
    </tr>
    <tr class="value">
        <td class="lRubrique"><p>Pertes connues</p></td>
        <?php echo $rowPc; ?>
    </tr>
    <tr class="value">
        <td class="lRubrique"><p>Repas du personnel</p></td>
        <?php echo $rowRp; ?>
    </tr>
    <tr class="value">
        <td class="lRubrique"><p>Alimentaire</p></td>
        <?php echo $rowA; ?>
    </tr>
    <tr class="value">
        <td class="lRubrique"><p>Alimentaire - Laboratoire</p></td>
        <?php echo $rowAl; ?>
    </tr>
    <tr class="value">
        <td class="lRubrique"><p>Total Alimentaire</p></td>
        <?php echo $rowTa; ?>
    </tr>
    <tr class="value">
        <td class="lRubrique"><p>Emballages</p></td>
        <?php echo $rowE; ?>
    </tr>
</table>
